

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>mindspore.scipy.linalg.eigh &mdash; MindSpore master documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="mindspore.scipy.linalg.inv" href="mindspore.scipy.linalg.inv.html" />
    <link rel="prev" title="mindspore.scipy.linalg.block_diag" href="mindspore.scipy.linalg.block_diag.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> MindSpore
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">MindSpore Python API</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../mindspore.html">mindspore</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.common.initializer.html">mindspore.common.initializer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.communication.html">mindspore.communication</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.compression.html">mindspore.compression</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.context.html">mindspore.context</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.html">mindspore.dataset</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.audio.html">mindspore.dataset.audio</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.config.html">mindspore.dataset.config</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.text.html">mindspore.dataset.text</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.transforms.html">mindspore.dataset.transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.dataset.vision.html">mindspore.dataset.vision</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.mindrecord.html">mindspore.mindrecord</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.html">mindspore.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.probability.html">mindspore.nn.probability</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.nn.transformer.html">mindspore.nn.transformer</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.numpy.html">mindspore.numpy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.ops.html">mindspore.ops</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.html">mindspore.parallel</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.parallel.nn.html">mindspore.parallel.nn</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.profiler.html">mindspore.profiler</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../mindspore.scipy.html">mindspore.scipy</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="../mindspore.scipy.html#mindspore-scipy-linalg">mindspore.scipy.linalg</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="mindspore.scipy.linalg.block_diag.html">mindspore.scipy.linalg.block_diag</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">mindspore.scipy.linalg.eigh</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.scipy.linalg.inv.html">mindspore.scipy.linalg.inv</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.scipy.linalg.lu.html">mindspore.scipy.linalg.lu</a></li>
<li class="toctree-l3"><a class="reference internal" href="mindspore.scipy.linalg.lu_factor.html">mindspore.scipy.linalg.lu_factor</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.scipy.html#mindspore-scipy-optimize">mindspore.scipy.optimize</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mindspore.scipy.html#mindspore-scipy-sparse-linalg">mindspore.scipy.sparse.linalg</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.train.html">mindspore.train</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mindspore.boost.html">mindspore.boost</a></li>
</ul>
<p class="caption"><span class="caption-text">MindSpore C++ API</span></p>
<ul>
<li class="toctree-l1"><a class="reference external" href="https://www.mindspore.cn/lite/api/zh-CN/master/api_cpp/mindspore.html">MindSpore Lite↗</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">MindSpore</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../mindspore.scipy.html">mindspore.scipy</a> &raquo;</li>
        
      <li>mindspore.scipy.linalg.eigh</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/api_python/scipy/mindspore.scipy.linalg.eigh.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="mindspore-scipy-linalg-eigh">
<h1>mindspore.scipy.linalg.eigh<a class="headerlink" href="#mindspore-scipy-linalg-eigh" title="Permalink to this headline">¶</a></h1>
<dl class="function">
<dt id="mindspore.scipy.linalg.eigh">
<code class="sig-prename descclassname">mindspore.scipy.linalg.</code><code class="sig-name descname">eigh</code><span class="sig-paren">(</span><em class="sig-param">a</em>, <em class="sig-param">b=None</em>, <em class="sig-param">lower=True</em>, <em class="sig-param">eigvals_only=False</em>, <em class="sig-param">overwrite_a=False</em>, <em class="sig-param">overwrite_b=False</em>, <em class="sig-param">turbo=True</em>, <em class="sig-param">eigvals=None</em>, <em class="sig-param">_type=1</em>, <em class="sig-param">check_finite=True</em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/mindspore/scipy/linalg.html#eigh"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#mindspore.scipy.linalg.eigh" title="Permalink to this definition">¶</a></dt>
<dd><p>Solve a standard or generalized eigenvalue problem for a complex Hermitian or real symmetric matrix.</p>
<p>Find eigenvalues Tensor <cite>w</cite> and optionally eigenvectors Tensor <cite>v</cite> of Tensor <cite>a</cite>,
where <cite>b</cite> is positive definite such that for every eigenvalue <cite>λ</cite> (i-th entry of w) and
its eigenvector <cite>vi</cite> (i-th column of <cite>v</cite>) satisfies:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>              <span class="n">a</span> <span class="o">@</span> <span class="n">vi</span> <span class="o">=</span> <span class="n">λ</span> <span class="o">*</span> <span class="n">b</span> <span class="o">@</span> <span class="n">vi</span>
<span class="n">vi</span><span class="o">.</span><span class="n">conj</span><span class="p">()</span><span class="o">.</span><span class="n">T</span> <span class="o">@</span> <span class="n">a</span> <span class="o">@</span> <span class="n">vi</span> <span class="o">=</span> <span class="n">λ</span>
<span class="n">vi</span><span class="o">.</span><span class="n">conj</span><span class="p">()</span><span class="o">.</span><span class="n">T</span> <span class="o">@</span> <span class="n">b</span> <span class="o">@</span> <span class="n">vi</span> <span class="o">=</span> <span class="mi">1</span>
</pre></div>
</div>
<p>In the standard problem, <cite>b</cite> is assumed to be the identity matrix.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>a</strong> (<a class="reference internal" href="../mindspore/mindspore.Tensor.html#mindspore.Tensor" title="mindspore.Tensor"><em>Tensor</em></a>) – A <span class="math notranslate nohighlight">\((M, M)\)</span> complex Hermitian or real symmetric matrix whose eigenvalues and
eigenvectors will be computed.</p></li>
<li><p><strong>b</strong> (<a class="reference internal" href="../mindspore/mindspore.Tensor.html#mindspore.Tensor" title="mindspore.Tensor"><em>Tensor</em></a><em>, </em><em>optional</em>) – A <span class="math notranslate nohighlight">\((M, M)\)</span> complex Hermitian or real symmetric definite positive matrix in.
If omitted, identity matrix is assumed. Default: None.</p></li>
<li><p><strong>lower</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>, </em><em>optional</em>) – Whether the pertinent Tensor data is taken from the lower or upper
triangle of <cite>a</cite> and, if applicable, <cite>b</cite>. Default: True.</p></li>
<li><p><strong>eigvals_only</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>, </em><em>optional</em>) – Whether to calculate only eigenvalues and no eigenvectors.
Default: False.</p></li>
<li><p><strong>_type</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em>, </em><em>optional</em>) – <p>For the generalized problems, this keyword specifies the problem type
to be solved for <cite>w</cite> and <cite>v</cite> (only takes 1, 2, 3 as possible inputs):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">1</span> <span class="o">=&gt;</span>     <span class="n">a</span> <span class="o">@</span> <span class="n">v</span> <span class="o">=</span> <span class="n">w</span> <span class="o">@</span> <span class="n">b</span> <span class="o">@</span> <span class="n">v</span>
<span class="mi">2</span> <span class="o">=&gt;</span> <span class="n">a</span> <span class="o">@</span> <span class="n">b</span> <span class="o">@</span> <span class="n">v</span> <span class="o">=</span> <span class="n">w</span> <span class="o">@</span> <span class="n">v</span>
<span class="mi">3</span> <span class="o">=&gt;</span> <span class="n">b</span> <span class="o">@</span> <span class="n">a</span> <span class="o">@</span> <span class="n">v</span> <span class="o">=</span> <span class="n">w</span> <span class="o">@</span> <span class="n">v</span>
</pre></div>
</div>
<p>This keyword is ignored for standard problems. Default: 1.</p>
</p></li>
<li><p><strong>overwrite_a</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>, </em><em>optional</em>) – Whether to overwrite data in <cite>a</cite> (may improve performance). Default: False.</p></li>
<li><p><strong>overwrite_b</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>, </em><em>optional</em>) – Whether to overwrite data in <cite>b</cite> (may improve performance). Default: False.</p></li>
<li><p><strong>check_finite</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>, </em><em>optional</em>) – Whether to check that the input matrices contain only finite numbers.
Disabling may give a performance gain, but may result in problems (crashes, non-termination)
if the inputs do contain infinities or NaNs. Default: True.</p></li>
<li><p><strong>turbo</strong> (<a class="reference external" href="https://docs.python.org/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>, </em><em>optional</em>) – use divide and conquer algorithm (faster but expensive in memory, only
for generalized eigenvalue problem and if full set of eigenvalues are requested.).
Has no significant effect if eigenvectors are not requested. Default: True.</p></li>
<li><p><strong>eigvals</strong> (<a class="reference external" href="https://docs.python.org/library/stdtypes.html#tuple" title="(in Python v3.8)"><em>tuple</em></a><em>, </em><em>optional</em>) – Indexes of the smallest and largest (in ascending order) eigenvalues
and corresponding eigenvectors to be returned: <span class="math notranslate nohighlight">\(0 &lt;= lo &lt;= hi &lt;= M-1\)</span>. If omitted, all eigenvalues
and eigenvectors are returned. Default: None.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><ul class="simple">
<li><p>Tensor with shape <span class="math notranslate nohighlight">\((N,)\)</span>, the <span class="math notranslate nohighlight">\(N (1&lt;=N&lt;=M)\)</span> selected eigenvalues, in ascending order,
each repeated according to its multiplicity.</p></li>
<li><p>Tensor with shape <span class="math notranslate nohighlight">\((M, N)\)</span>, (if <code class="docutils literal notranslate"><span class="pre">eigvals_only</span> <span class="pre">==</span> <span class="pre">False</span></code>)</p></li>
</ul>
</p>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>LinAlgError</strong> – If eigenvalue computation does not converge, an error occurred, or b matrix is not
    definite positive. Note that if input matrices are not symmetric or Hermitian, no error will
    be reported but results will be wrong.</p>
</dd>
</dl>
<dl class="simple">
<dt>Supported Platforms:</dt><dd><p><code class="docutils literal notranslate"><span class="pre">CPU</span></code> <code class="docutils literal notranslate"><span class="pre">GPU</span></code></p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">mindspore.numpy</span> <span class="k">as</span> <span class="nn">mnp</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">mindspore.common</span> <span class="kn">import</span> <span class="n">Tensor</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">mindspore.scipy.linalg</span> <span class="kn">import</span> <span class="n">eigh</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">Tensor</span><span class="p">([[</span><span class="mf">6.</span><span class="p">,</span> <span class="mf">3.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">,</span> <span class="mf">5.</span><span class="p">],</span> <span class="p">[</span><span class="mf">3.</span><span class="p">,</span> <span class="mf">0.</span><span class="p">,</span> <span class="mf">5.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">],</span> <span class="p">[</span><span class="mf">1.</span><span class="p">,</span> <span class="mf">5.</span><span class="p">,</span> <span class="mf">6.</span><span class="p">,</span> <span class="mf">2.</span><span class="p">],</span> <span class="p">[</span><span class="mf">5.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">,</span> <span class="mf">2.</span><span class="p">,</span> <span class="mf">2.</span><span class="p">]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">w</span><span class="p">,</span> <span class="n">v</span> <span class="o">=</span> <span class="n">eigh</span><span class="p">(</span><span class="n">A</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mnp</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">mnp</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">A</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span> <span class="o">-</span> <span class="n">mnp</span><span class="o">.</span><span class="n">dot</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="n">mnp</span><span class="o">.</span><span class="n">diag</span><span class="p">(</span><span class="n">w</span><span class="p">)))</span> <span class="o">&lt;</span> <span class="mf">1e-10</span>
<span class="go">Tensor(shape=[], dtype=Bool, value= True)</span>
</pre></div>
</div>
</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="mindspore.scipy.linalg.inv.html" class="btn btn-neutral float-right" title="mindspore.scipy.linalg.inv" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="mindspore.scipy.linalg.block_diag.html" class="btn btn-neutral float-left" title="mindspore.scipy.linalg.block_diag" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2021, MindSpore.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>